package com.study.designmodes.controller.component;

import com.study.designmodes.request.User;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

/**
 * 日志脱敏控制器
 *
 * @author yangyanbin
 * @date 2023/02/03
 * @since 20230203
 */
@RestController
@Slf4j
public class DesensitizationController {

    @GetMapping("/info")
    public String logInfo() {
        log.info("localMobile:{},localMobile:{},", "023-3232344", "123456");
        return "日志数据脱敏";
    }

    /**
     * 注解搞定接口返回数据脱敏
     *
     * @return
     */
    @GetMapping("/ObjectDataMasking")
    public User dataMasking() {
        User user = new User();
        user.setAge(1000);
        user.setEmail("22323232423@qq.com");
        user.setName("liSi");
        user.setAge(100);
        return user;


    }

    /**
     * 注解搞定接口返回数据脱敏
     *
     * @return
     */
    @GetMapping("/ListDataMasking")
    public List<User> dataListMasking() {
        List<User> list = new ArrayList<>();
        User user1 = new User();
        user1.setAge(1000);
        user1.setEmail("22323232423@qq.com");
        user1.setName("liSi");
        user1.setAge(100);

        User user2 = new User();
        user2.setAge(1000);
        user2.setEmail("3334444343@qq.com");
        user2.setName("linli");
        user2.setAge(1000);

        list.add(user1);
        list.add(user2);

        //user1.setUserList(list);

        return list;

    }

    /**
     * 注解搞定接口返回数据脱敏
     *
     * @return
     */
    @GetMapping("/DataObjectListMasking")
    public User dataObjectListMasking() {

        User user1 = new User();
        user1.setAge(1000);
        user1.setEmail("22323232423@qq.com");
        user1.setName("liSi");
        user1.setAge(100);

        User user2 = new User();
        user2.setAge(1000);
        user2.setEmail("@qq.com");
        user2.setName("linli");
        user2.setAge(1000);
        List<User> list = new ArrayList<>();
        list.add(user2);

        user1.setUserList(list);


        //user1.setUserList(list);

        return user1;

    }
}
